package archer.back.utils

import net.scalax.cpoi.api._
import org.apache.poi.ss.usermodel.{ CellStyle, VerticalAlignment, Workbook }

object PoiStyles {

  case class DateFormat(format: String) extends StyleTransform {
    override def operation(
      workbook: Workbook,
      cellStyle: CellStyle): CellStyle = {
      cellStyle.setDataFormat(workbook.createDataFormat().getFormat(format))
      cellStyle
    }
  }

  case class BigDecimalFormat(format: String) extends StyleTransform {
    override def operation(
      workbook: Workbook,
      cellStyle: CellStyle): CellStyle = {
      cellStyle.setDataFormat(workbook.createDataFormat().getFormat(format))
      cellStyle
    }
  }

  case class TextFormat() extends StyleTransform {
    override def operation(
      workbook: Workbook,
      cellStyle: CellStyle): CellStyle = {
      cellStyle.setDataFormat(workbook.createDataFormat().getFormat("@"))
      cellStyle
    }
  }

  case class VerticalCenter() extends StyleTransform {
    override def operation(
      workbook: Workbook,
      cellStyle: CellStyle): CellStyle = {
      cellStyle.setVerticalAlignment(VerticalAlignment.CENTER)
      cellStyle
    }
  }

}
